Cache benchmark results by base commit - #11684
Conversation
Resolve PR revisions from trusted GitHub metadata before executing benchmark code. Retain and update checked-in baseline results with commit provenance, and add a notebook for benchmark history visualization and dashboard export.
Run candidate benchmarks in an unprivileged pull_request workflow and move trusted base caching, reporting, and baseline persistence to workflow_run. Authorize measured runs through maintainer-triggered reruns and update tests and documentation.
Export PNG previews alongside SVG dashboard charts and improve the single-baseline layout until additional hosted runs accumulate.
Run the repository's pinned Prettier formatter after notebook dashboard generation and commit the formatted HTML output.
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
| ], | ||
| }) | ||
| const commit = await github.rest.git.createCommit({ | ||
| owner: context.repo.owner, |
There was a problem hiding this comment.
Issue · Please address or respond
Historical identity uses only result.date, so distinct base commits measured on the same UTC day target the same file and cannot both be retained. Include the source SHA or timestamp in the filename and add coverage for two same-day revisions.
[verified]
|
|
||
| permissions: | ||
| contents: read | ||
| issues: read |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Does issues: read authorize github.rest.pulls.get here? This workflow does not grant pull-requests: read, so requested reruns may receive a 403 while checking the PR. Add that permission or use an endpoint covered by the granted permissions.
| issue_number: issueNumber, | ||
| name: 'benchmark-requested', | ||
| }) | ||
| } catch (error) { |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Cleanup for an older report unconditionally removes the PR-wide request label, so a second /benchmark request made while that report is finishing can lose authorization before its rerun checks the label. Bind cleanup to a request/run identity or remove the label before rerunning, and test overlapping requests.
|
Result: Verification detailsVerification: Isolated verification observed failures that were not classified as caused by this PR: Module-style benchmark test invocation, Benchmark unittest suite. Summary: Five new comparator/profile tests passed. The 52-test benchmark suite ran 50 tests successfully, but two workflow tests errored because the container lacks Node.js. Verification is therefore partial; no PR-caused assertion failure was observed. Test runs: 1 passed, 2 failed
❌
|
Summary
maincommit used to create that merge.What is compared
The candidate is GitHub's synthetic merge commit, which combines the PR's current head with its current
mainbase. The baseline is that same exactmainbase commit:This measures the performance impact the PR would have after merging. It does not compare the PR with its initial commit, benchmark the raw PR head alone, or compare against a moving newer
main. If the PR head or base changes before trusted reporting validates the revisions, the report stops and/benchmarkmust be requested again.Security and behavior
/benchmarkis restricted to maintainers and reruns an existing unprivilegedpull_requestworkflow.workflow_runcode.${{ github.sha }}; candidate output crosses the boundary only as bounded, provenance-validated JSON.latestbaseline files only for same-repository PRs whose head has not changed.Benchmark history
Checked-in results under
build/benchmark/baselines/include the source commit SHA, subject, and timestamp.build/benchmark/benchmark_history.ipynbgraphs execution-time and peak-memory changes across those main commits and can export a static dashboard underdocs/benchmark-results/.Dashboard preview
The checked-in history currently contains one hosted
mainbaseline, so these previews show the initial package measurements. Lines and commit-over-commit changes will appear as dated runs accumulate.Execution time
Peak memory
After merge, the full dashboard will be available at https://microsoft.github.io/pyright/benchmark-results/.
Validation
python -m unittest discover -s build/benchmark -p "test_*.py"(52 tests)